/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2007 John Platts. All rights reserved.
 *
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common
 * Development and Distribution License("CDDL") (collectively, the
 * "License"). You may not use this file except in compliance with the
 * License. You can obtain a copy of the License at
 * http://www.netbeans.org/cddl-gplv2.html
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 * specific language governing permissions and limitations under the
 * License.  When distributing the software, include this License Header
 * Notice in each file and include the License file at
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the GPL Version 2 section of the License file that
 * accompanied this code. If applicable, add the following below the
 * License Header, with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * Contributor(s):
 *
 * The Original Software is nbgeronimo. The Initial Developer of the Original
 * Software is John Platts. Portions Copyright 2007 John Platts.
 * All Rights Reserved.
 *
 * If you wish your version of this file to be governed by only the CDDL
 * or only the GPL Version 2, indicate your decision by adding
 * "[Contributor] elects to include this software in this distribution
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 * single choice of license, a recipient has the option to distribute
 * your version of this file under either the CDDL, the GPL Version 2 or
 * to extend the choice of license to its licensees as provided above.
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 * Version 2 license, then the option applies only if the new code is
 * made subject to such option by the copyright holder.
 */

package net.sourceforge.nbgeronimo.ui;

import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider;
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
import org.openide.util.NbBundle;

/**
 *
 * @author  John Platts
 */
public class PathView extends javax.swing.JPanel {
    private String type ;
    private J2eePlatformImpl platform ;
    
    static final String CLASSPATH = J2eeLibraryTypeProvider.VOLUME_TYPE_CLASSPATH;
    static final String SOURCES = J2eeLibraryTypeProvider.VOLUME_TYPE_SRC;
    static final String JAVADOC = J2eeLibraryTypeProvider.VOLUME_TYPE_JAVADOC;
    
    /** Creates new form PathView */
    public PathView(J2eePlatformImpl platform, String type) {
        this.type = type ;
        this.platform = platform ;
        
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        label = new javax.swing.JLabel();
        spane = new javax.swing.JScrollPane();
        resources = new javax.swing.JList();

        setLayout(new java.awt.GridBagLayout());

        label.setLabelFor(resources);
        label.setText(org.openide.util.NbBundle.getMessage(PathView.class, "PathView.label.text")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(6, 12, 2, 0);
        add(label, gridBagConstraints);

        spane.setPreferredSize(new java.awt.Dimension(200, 100));
        spane.setViewportView(resources);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridheight = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 6);
        add(spane, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents
    
    private void doAdditionalInitialization()
    {
        String labelKey = null ;
        String mnemonicKey = null ;
        String accessibleDescrKey = null ;
        if(type.equals(CLASSPATH)) {
            labelKey           = "TXT_Classes" ;
            mnemonicKey        = "MNE_Classes" ;
            accessibleDescrKey = "AD_Classes" ;
        }
        else if(type.equals(SOURCES)) {
            labelKey           = "TXT_Sources" ;
            mnemonicKey        = "MNE_Sources" ;
            accessibleDescrKey = "AD_Sources" ;
        }
        else if(type.equals(JAVADOC)) {
            labelKey           = "TXT_Javadoc" ;
            mnemonicKey        = "MNE_Javadoc" ;
            accessibleDescrKey = "AD_Javadoc" ;
        }
        else {
            assert false : "Illegal type of panel";
            return ;
        }
        
        label.setText(NbBundle.getMessage(PathView.class, labelKey)) ;
        label.setDisplayedMnemonic(NbBundle.getMessage(PathView.class, mnemonicKey).charAt(0)) ;
        resources.setModel(new PathModel(platform, type));
        resources.getAccessibleContext().setAccessibleDescription(
                NbBundle.getMessage(PathView.class, accessibleDescrKey)) ;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel label;
    private javax.swing.JList resources;
    private javax.swing.JScrollPane spane;
    // End of variables declaration//GEN-END:variables
    
}
